#include "door.hpp"

#include "vec.hpp"

static const Vec2f SIZE (1, 6);

#include "image.hpp"
#include "sound.hpp"

static Image *doorimg;
static Sound *doorsnd;

bool Door::Open()
{
	doorimg = AllImgs.Get("door");
	doorsnd = AllSnds.Get("door");

	return true;
}

#include "cue.hpp"

void Door::Init(float x, float y, Cue & cue)
{
	hp = 1;
	body.size = SIZE;
	body.pos.x = x;
	body.pos.y = y;
	dir = cue.Dir();
	img = doorimg;
}

#include <algorithm>

void Door::Update()
{
	frame += dframe;
	if (dframe)
		if (frame == 0.f || frame == 2.f)
		{
			dframe = 0;
			snd = doorsnd;
		}
}

#include "player.hpp"

void Door::Hit(Player & plr)
{
}

static const float FPU = .125f;

void Door::Shut(bool shut)
{
	dframe = shut ? -FPU : FPU;
}

bool Door::IsShut()
{
	return frame == 0;
}

ActPool<Door, Door::COUNT> Doors;
